<%@ page import="java.util.List" %>
<%@ page import="java.util.ArrayList" %>
<%@ page import="web.servlet.eljstl.User" %>
<%@ page import="java.util.Date" %><%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2020/6/11
  Time: 15:25
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
    <title>JSTL标签</title>
</head>
<body>
<%
    List<String> list=new ArrayList<String>();
    list.add("drg");
    list.add("efe");
    request.setAttribute("list",list);
    request.setAttribute("number",5);
    List<String> list1=new ArrayList<String>();
    request.setAttribute("list1",list1);
%>
<h2>if标签</h2>
<%--判断list是否为空--%>
<c:if test="${not empty list}">
    ${list}<br>
    ${list[0]}<br>
    ${list[1]}<br>
</c:if>
<c:if test="${empty list1}">
    null<br>
</c:if>
<%--判断number奇偶--%>
<c:if test="${number%2==0}">
    ${number}是偶数<br>
</c:if>
<c:if test="${number%2!=0}">
    ${number}是奇数<br>
</c:if>
<h2>foreach标签</h2>
<c:forEach begin="0" end="1" var="i" step="1" varStatus="s">
    ${i}<br>
    ${s.index}<br>
    ${s.count}<br>
    <hr>
    ${list[i]}<br>
</c:forEach>
<%
    User u1=new User("张三",18,new Date());
    User u2=new User("ege",14,new Date());
    User u3=new User("egh",17,new Date());
    List<User> userList=new ArrayList<User>();
    userList.add(u1);
    userList.add(u2);
    userList.add(u3);
    request.setAttribute("userLiset",userList);
%>
<c:forEach items="${userLiset}" var="u" varStatus="s">
    ${u}<br>
    ${u.name}<br>
    ${s.index}<br>
    ${s.count}<br>
    <hr>
</c:forEach>
</body>
</html>
